<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=D6WOzHaymzVVKvgiy8UbhQEznkgeK6BD"></script>
    <script src="./jquery.min.js"></script>
    <title>Document</title>
</head>

<body>
    <div id="point">qq</div>
    <div id="loca">111</div>

    <div id="ser">1222</div>

    <div id="res">结果</div>
    <div id="res1">结果</div>
        <script>
            $(function () {
                navigator.geolocation.getCurrentPosition(translatePoint); //定位
            });
            function translatePoint(position) {
                var currentLat = position.coords.latitude;
                var currentLon = position.coords.longitude;
         
                //输出经纬度
                $("#point").attr('value', currentLon + "," + currentLat);
                $("#point").html(currentLon+'111'+currentLat)
                // var gpsPoint = new BMap.Point(currentLon, currentLat);
                // BMap.Convertor.translate(gpsPoint, 0, initMap); //转换坐标
                setTimeout(function () {
                var gpsPoint = new BMap.Point(longitude, latitude);
                alert("gpsPoint="+gpsPoint)
                BMap.Convertor.translate(gpsPoint, 0, function (point) {
                    alert(1)
                    alert(point)
                    var geoc = new BMap.Geocoder();
                    geoc.getLocation(point, function (rs) {
                        var addComp = rs.addressComponents;
                        var aaa=addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber
                        $('#res').html(aaa)
                        $('#res1').html(rs)
                    });
                });
            }, 5000);
            }
            // function initMap(point) {
         
            //     var geoc = new BMap.Geocoder();
         
            //     geoc.getLocation(point, function (rs) {
            //         var addComp = rs.addressComponents;
            //         //alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
            //         var location = addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber;
                   
            //         //输出地址
            //         $("#ser").html('请求成功')
            //         $("#loca").html(location);
            //         $("#location").attr('value', addComp.city);
         
            //     });
         
            // }

               
        
   
        </script>
        
</body>
</html>